<?php
namespace  App\Service\Customer;

use App\Common\Fun;

class CustomerProgram
{
    /**
     *  发送小程序登入验证
     */
    public static function sendCode2Session($code)
    {
        $config = config('program');

        $res = Fun::sendUrl('get',$config['code2Session_url'],[
            'appid' => $config['appid'],
            'secret' => $config['secret'],
            'js_code' => $code,
            'grant_type' => $config['grant_type']
        ]);
        $res = json_decode($res,true);

        if(isset($res['errcode']) && $res['errcode'] != 0){
            throw new \Exception($res['errmsg']);
        }
        return $res;
    }
}